#include <list>
#include <iterator>
#include <iostream>

using namespace std;

int main(){
	list<string * > str;
	list<string * > ::iterator iter;
	while(1){
	str.push_back(new string("hello"));
	str.push_back(new string("hello1"));
	str.push_back(new string("hello2"));

	for( iter = str.begin() ; iter != str.end() ; ) {
//		cout << *(*iter) <<endl;
		delete *iter;
		iter = str.erase( iter );
//		--iter;
//		iter->erase();
	}
//	cout << "******************" <<endl;
	}
	str.push_back(new string("hello3"));
	str.push_back(new string("hello4"));
	str.push_back(new string("hellot"));
	for( iter = str.begin() ; iter != str.end() ; iter++) {
		cout << *(*iter) <<endl;
//		iter->erase();
	}
	
	return 0;
}
